<template>
    <div>
        <a-form-item label="用户名" v-bind="formlayout">
      <a-input v-model="username" placeholder="请输入用户名"></a-input>
    </a-form-item>


    <a-form-item label="昵称" v-bind="formlayout">
      <a-input v-model="nickname" placeholder="请输入昵称"></a-input>
    </a-form-item>

    <a-form-item label="手机号" v-bind="formlayout">
      <a-input v-model="phone" placeholder="请输入手机号"></a-input>
    </a-form-item>

    <a-form-item label="邮箱" v-bind="formlayout">
      <a-input v-model="email" placeholder="请输入邮箱"></a-input>
    </a-form-item>

    <a-form-item v-bind="buttonlayout">
      <a-button type="primary" @click="update_user">修改</a-button>
    </a-form-item>
    
    </div>
</template>


<script>
import { put_user } from './axios_http/api'

export default {
data() {
        return {
            uid: this.$route.query.uid,
            username: '',
            phone: '',
            nickname: "",
            email: "",
            // 表单样式
            formlayout:{
                // 标签
                labelCol:{
                    xs:{span:24},
                    sm:{span:8}
                },
                // 文本框
                wrapperCol:{
                    xs:{span:24},
                    sm:{span:8}
                }
            },
            
            // 按钮样式
            buttonlayout:{
                // 按钮
                wrapperCol:{
                    xs:{span:24,offset:0},
                    sm:{span:16,offset:8}
                },
            },
        }
    },
    methods: {
        update_user(){
            let data = {
                uid: this.uid,
                username: this.username,
                phone: this.phone,
                nickname: this.nickname,
                email: this.email,
            }
            console.log(data)
            put_user(data).then((resp) => {
                this.$message.info(resp.data)
                if(resp.data == "修改成功"){
                    this.$router.push('/home')
                }
            })
        }
    }
};
</script>